﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Lokad.Monitoring.Persistence.Entities
{
    public class Endpoint
    {
        [DisplayName("Endpoint name (16 char max, alphanumerical)")]
        [Required(ErrorMessage = "Endpoint name is required.")]
        public virtual string Id { get; set; }

        [Required(ErrorMessage = "URL is required.")]
        public virtual string Url { get; set; }

        [DisplayName("Optional credential for basic auth (login:password)")]
        public virtual string BasicAuth { get; set; }

        [DisplayName("Retrieval frequency (in seconds, zero to disable retrieval)")]
        [Range(0, 1000000, ErrorMessage = "Should be comprised between 0 and 1 million.")]
        public virtual int Frequency { get; set; }

        public virtual DateTime LastRetrieved { get; set; }

        public virtual IList<Response> Responses { get; set; }

        public Endpoint()
        {
            Responses = new List<Response>();
        }
    }
}
